home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / dcgames4.zip / DCSCRIPT.DOC < prev    next >
Text File  |  1995-10-02  |  76KB  |  2,696 lines

  1. Introduction     1 
  2.  
  3. Preface     1 
  4.  
  5. Document Organization     1 
  6.  
  7. Conventions     2 
  8.  
  9. Getting Help     2 
  10.  
  11. Basic Information     3 
  12.  
  13. What is a script?     3 
  14.  
  15. What is a script used for?     3 
  16.  
  17. Character scripts     3 
  18.  
  19. Object scripts     4 
  20.  
  21. World script.     5 
  22.  
  23. Control script     5 
  24.  
  25. Magic Spells     5 
  26.  
  27. Game Initialization Script     6 
  28.  
  29. Dead and Resurrection     6 
  30.  
  31. Basic Script Elements     7 
  32.  
  33. Keywords     7 
  34.  
  35. Keywords Table     8 
  36.  
  37. Comments     8 
  38.  
  39. Numbers     9 
  40.  
  41. Tokens     9 
  42.  
  43. Variables     10 
  44.  
  45. Generic Variables (Local and Global)     10 
  46.  
  47. String Variables     10 
  48.  
  49. World Variables and Attributes     11 
  50.  
  51. Object Variables and Attributes     11 
  52.  
  53. Character Variables and Attributes     13 
  54.  
  55. Group Variables and Attributes     14 
  56.  
  57. Types of Scripts     15 
  58.  
  59. Introduction Script     15 
  60.  
  61. Character Script     16 
  62.  
  63. Object Script     17 
  64.  
  65. World Script     18 
  66.  
  67. Control Script     18 
  68.  
  69. Resurrection Script     18 
  70.  
  71. Writing Scripts     19 
  72.  
  73. Script Files     19 
  74.  
  75. Expressions and Assignments     20 
  76.  
  77. Function Table     21 
  78.  
  79. Statements     22 
  80.  
  81. Conditional Statements     22 
  82.  
  83. Flow Control Statements     23 
  84.  
  85. Flow control using if     23 
  86.  
  87. Flow control using on-goto     23 
  88.  
  89. Loop Control Statements     24 
  90.  
  91. The while statement     24 
  92.  
  93. The for statement     24 
  94.  
  95. The foreach statement     24 
  96.  
  97. Object Manipulation Statements     25 
  98.  
  99. Move and Copy     25 
  100.  
  101. Drop     25 
  102.  
  103. Output Statements     25 
  104.  
  105. Write and Writeln     25 
  106.  
  107. Display     26 
  108.  
  109. Input Statements     26 
  110.  
  111. Getstr and Getnum     26 
  112.  
  113. Select     26 
  114.  
  115. Going Places     26 
  116.  
  117. Animation     27 
  118.  
  119. Entering Doors     27 
  120.  
  121. Teleportation     27 
  122.  
  123. Advanced Topics     27 
  124.  
  125. Entry Points     27 
  126.  
  127. Calling A DOS program     28 
  128.  
  129. Creating New Types and Classes     29 
  130.  
  131. New Character Types     29 
  132.  
  133. New Character Classes     29 
  134.  
  135. New Object Types     30 
  136.  
  137. New Object Classes     30 
  138.  
  139. New Object Modifiers     31 
  140.  
  141. New World Types     32 
  142.  
  143. Shareware Opportunities     33 
  144.  
  145. Extending the magic system     33 
  146.  
  147. MS-DOS based extensions     33 
  148.  
  149. Writing a whole new system     34 
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. D C  -  G A M E S 
  170.  
  171.  
  172.  
  173.  
  174.  
  175. Version 4.0
  176.  
  177.  
  178.  
  179. SCRIPT LANGUAGE USER'S GUIDE
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. August 1995
  200.  
  201.  
  202.  
  203.  
  204.  
  205. (c) DC Software, 1989-1995
  206.  
  207. 7908 Kettlewood Court
  208.  
  209. Plano TX 75025
  210.  
  211. (214) 491-1579 Introduction
  212.  
  213. Preface
  214.  
  215. One of the goals of the DCGAMES adventure and role-playing game
  216. building system is to provide an environment in which you can
  217. create adventure games without having to know anything about
  218. computer programming, and without having to maintain a zillion
  219. lists of cryptic numbers.  If you want to draw a river, you just
  220. do it.  If you want to create a dragon, just grab the right
  221. picture and do it.  The idea is to have a large enough set of
  222. objects, characters, monsters and landscaping to allow you to
  223. concentrate on the story.
  224.  
  225. While this works fine most of the time, it is almost inevitable
  226. that there will be a few things you need to do that I didn't
  227. think of, or which need to work slightly different.  You may
  228. need a new type of character or object, or some new magic
  229. spells.  Maybe the wizards are too wimpy or elves and dwarfs
  230. should not exist in your adventure.
  231.  
  232. Most of the features in the DCGAMES system are handled by
  233. scripts.  The script language is a simple yet powerful language
  234. that the game driver understands, and which control the behavior
  235. of most parts of the game system.
  236.  
  237. The scripts are created using a standard text editor, and can be
  238. as simple or complex as you need them to be.  While you can
  239. write a complete game without writing a single line of script, a
  240. small effort on your part to learn how to write script will
  241. result in significantly better games, since you can fine-tune
  242. your creation to work exactly the way you want it to work.
  243.  
  244. Document Organization
  245.  
  246. This manual is organized in several sections.  The first one is
  247. an introduction to the elements of the DCGAMES system.  It
  248. explains each of the building blocks used to create an
  249. adventure, and how (and why) you would want to customize them. 
  250. Everyone should read this section!
  251.  
  252. The second section is a Reference Manual, which is a list of the
  253. features of the script language in a logical order.  You will
  254. need a printed copy of that section of the manual when you are
  255. actually writing a script.
  256.  
  257. Conventions
  258.  
  259. In this document, the following conventions are used:
  260.  
  261. UPPER-CASE-WORDS
  262.  
  263. represent tokens that have a specific value and are typed
  264. exactly as shown.
  265.  
  266. italic-words
  267.  
  268. are used when a new concept is being introduced, and the world
  269. in italics is the name of that concept.  They are also used to
  270. indicate that you should be replace the word with an appropriate
  271. name or value.
  272.  
  273. bold-words
  274.  
  275. represent names or values that should be typed exactly as shown.
  276.  
  277. text1 | text2
  278.  
  279. items separated by a vertical bar (|) mean you get to choose one
  280. of them.
  281.  
  282. [text1 ]
  283.  
  284. items enclosed in square brackets are optional.  If multiple
  285. items are listed, separated by a vertical bar, then you may
  286. choose one of them or none.
  287.  
  288. { text1 | text2 }
  289.  
  290. items enclosed in curly braces are NOT optional.  You must
  291. select one of the items listed.
  292.  
  293. ...
  294.  
  295. three dots (ellipsis) indicate that the previous item can be
  296. repeated multiple times.  If there is a limit to the number of
  297. times an item can be repeated, it will be indicated in a note
  298. near the area where the ellipsis were used.
  299.  
  300. Getting Help
  301.  
  302. Registered users of DCGAMES get free telephone assistance
  303. evenings and weekends.  This assistance may range from
  304. explaining how a certain feature works to guidance in how to add
  305. a new feature.  I might even write some specialized scripts for
  306. you (within reason).
  307.  
  308. Non-registered users are welcome to call also.  I will try to
  309. answer questions over the phone, but please keep your questions
  310. simple and organized.  If you feel you can't afford to pay for
  311. the game, I've been known to accept a smaller amount or even
  312. waive the fee in exchange for some serious feed back or some
  313. outstanding artwork or sound recordings that I may incorporate
  314. into the shareware product. Basic Information
  315.  
  316. Who should read this guide?
  317.  
  318. You need to read this guide if you are already familiar with the
  319. DCGAMES system and are ready to extend or modify the system to
  320. suit a particular game's requierments.
  321.  
  322. It is very important that you be familiar with the world builder
  323. program (DCWORLD) before you try to modify the scripts.
  324.  
  325. What is a script?
  326.  
  327. A script is a text file, created using a simple text editor (If
  328. you use a word processor, be sure to store the file in 'ASCII'
  329. or 'PLAIN TEXT' format).
  330.  
  331. The script file contains the instructions that tell the game
  332. driver (DCPLAY program) how to handle most aspects of the game. 
  333. The system includes a large number of predefined scripts to
  334. handle objects, characters, worlds, etc.  You can modify these
  335. scripts to meet your game's individual requirements, and you can
  336. write whole new scripts to extend the number of options you have.
  337.  
  338. The DCGAMES system includes a large set of predefined scripts
  339. which are used to handle your game.  While these scripts are
  340. complete, you may want to modify them or write new scripts to
  341. handle your specific needs. The type of script you write depends
  342. on the aspect of the game that you want to control.
  343.  
  344. The script language was designed to be easy to learn and use. 
  345. The documentation was written specifically for people that have
  346. no prior exposure to programming, and the predefined scripts
  347. have extensive annotations to help you understand them and learn
  348. from them.
  349.  
  350. A good thing to remember is that you cannot cause any damage
  351. through experimentation.  The worst you can do is to make some
  352. changes to a script that prevent it from operating properly.  
  353. All you have to do is retrieve a copy of the original script
  354. (which you saved before you modified the script, right? right!) 
  355. or at worst, you can give me a call and I will help you fix it.
  356. Don't be afraid to try!
  357.  
  358. What types of scripts are there?
  359.  
  360. Every aspect of the game is controled by scripts to a large
  361. extent. These scripts call other scripts which in turn may call
  362. other scripts themselves.
  363.  
  364. Control scripts
  365.  
  366. The CONTROL script is called every time you click with the mouse
  367. or press a key on the keyboard.  This script decides what action
  368. to take based on your input.  Thus, while the default control
  369. script interprets the letter A to mean 'attack' and a click in
  370. the view area with the left mouse button to mean 'look-at', you
  371. can modify the complete interface to do whatever you want.
  372.  
  373. The control script is also called every 'minute' of game play.
  374. Using the world builder you can specify how time flows in your
  375. game (# of moves per minute, # of minutes per hours, # of hours
  376. per day, # of days per month, # of months per year, current
  377. date, etc.).  The game driver then invokes the control script to
  378. keep track of time and allow it to take time dependent actions.
  379.  
  380. Game Initialization Script
  381.  
  382. When the game first starts, the INITGAME script will be invoked.
  383.  This script is used to present the game's story.  You can use
  384. voice, music, graphics, text, animation, etc.
  385.  
  386. Within this script you also have the chance to create and
  387. customize the player's character or even the whole party. The
  388. default character stored in record 0 of the statistics file
  389. (PLAYERS.DTA) will be used if you don't create one.
  390.  
  391. Dead and Resurrection
  392.  
  393. The RESURECT script is invoked whenever all members of the party
  394. die. In this script you have the chance to load a saved game,
  395. restart the game from the begining or even resurect the party
  396. members.
  397.  
  398. The default resurection script will restore the party members a
  399. limited number of times by comparing the number of times they
  400. have been resurected with the current experience level. It then
  401. transports the party to the place where the game started.
  402.  
  403. Remember that you can set the rules and do whatever you want.
  404. Some games I've seen will reduce an individual's experience as a
  405. penalty for resurection but leave them where they were. Others
  406. will teleport the party to a different location for resurection.
  407.  
  408. Character scripts.
  409.  
  410. When the control script determines that you want to interact
  411. with another character, it invokes the character's script to
  412. handle the interaction.
  413.  
  414. Every character in your game has a character type that
  415. determines it's behaviour. The list of character types is
  416. defined in the DCCTOKEN.DAT file and the behaviour is handled by
  417. a script with the same name as the character type.
  418.  
  419. DCGAMES includes a full set of character types with their
  420. respective scripts:  Regular, Bartender, Beggar, Civilian,
  421. Guard, Healer, Merchant, Prisoner, Teller and Trainer.  
  422.  
  423. The behavior of these character types is described in detail in
  424. the DCGAMES Player's Guide.  One of the best ways to become
  425. quickly familiar with the script language is to compare the
  426. description of the character type as documented in the Player's
  427. Guide with the actual script that makes the character behave
  428. that way.
  429.  
  430. To create your own character types, you add the name of the
  431. character type to the list in DCCTOKEN.DAT and then create a
  432. script with that name to handle it's behaviour. If a name is
  433. longer than 8 characters, you use the first 8 characters for the
  434. script name.
  435.  
  436. Note: individual characters can have their own individual script
  437. to override some or all of the character's standard behaviour.
  438. When a character has it's own script, the driver allows the
  439. character's script to handle the behaviour and invokes the
  440. default script for the character's type only if the individual
  441. script does not handle a particular action.
  442.  
  443. Object scripts.
  444.  
  445. When the control script determines that you want to use an
  446. object in some way, it invokes the object's script to handle the
  447. action.
  448.  
  449. If the action is on an object you are carrying, the CURRITEM
  450. script is invoked.  If the action is on an object you are not
  451. carrying, the OBJECT script is invoked.
  452.  
  453. These two scripts handle the standard behaviour for all of the
  454. object types defined in DCCTOKEN.DAT.  You can add new types to
  455. the list and modify these scripts to handle actions on the new
  456. object types.
  457.  
  458. The default scritps handle Food, Weapon, Ammunition, Armor,
  459. Shield, Amulet, Ring, Potion, Scroll, Staff, Chest, Keys, Gems,
  460. Book, Gold Sack, Torch, Lantern, Rope, Hooks, Mirror, Sign,
  461. Vehicle, Thing, Door and Fence objects.
  462.  
  463. You can also override an object's default behaviour by providing
  464. a tailor-made script for that particular object. Any action 
  465. that is not handled by your script will be handed over to the
  466. default script for handling.
  467.  
  468. You can alter the behavior of an object in several ways. You may
  469. modify the OBJECT.SCR to alter the way existing objects types
  470. work, or define new object types; You can also create a brand
  471. new script file to control the behavior of a specific object.
  472.  
  473. World scripts.
  474.  
  475. When the player enters or exists a world, the world's script is
  476. executed. The predefined script WORLDDEF.SCR is executed if you
  477. don't provide one of your own. The world's script can deny
  478. access to the world, or send the character to a different
  479. destination within the same world or in any other world.
  480.  
  481. The file DCCTOKEN.DAT contains a list of world types (Outdoors,
  482. City, Town, Dungeon, Hideout, House, Castle, Arena, Haunted and
  483. End-Game) which you can modify at will.
  484.  
  485. The world script handles entry and exit from each world, but
  486. other scripts are also involved.  For example, the CONTROL
  487. script will generate random monsters only in OUTDOORS, DUNGEON 
  488. and HAUNTED worlds. It also handles walking of the 'edge' of the
  489. world (if outdoors you wrap around to the other edge of the
  490. world, but in cities and towns you 'leave' the world).
  491.  
  492. Magic Spells
  493.  
  494. When you invoke magic by using an object, the OBJECT and
  495. CURRITEM scripts handle the action, but when a magic users
  496. 'casts' a spell, no object is involved, so a separate script is
  497. used.  The CASTING script handles the casting of magic spells.
  498.  
  499. For more information on magic, see the Player's Guide and the
  500. World Builder User's Guide.
  501.  
  502. Basic Script Elements
  503.  
  504. This section introduces the basic elements that form the script
  505. language. Just like in English you use words to build sentences,
  506. and those words are classified into verbs, adjectives, etc, so
  507. does the script language use a basic set of elements to build
  508. it's sentences.
  509.  
  510. The script language contains the following basic elements:
  511. Keywords, Tokens, Constants,  Variables, Structures, Statements,
  512. Functions, Procedures, Comments.  Let's look at each one in turn.
  513.  
  514. Keywords
  515.  
  516. A keyword is a word that has a special meaning in the script
  517. language. You cannot change the spelling or meaning of the
  518. keyword, because the game system has a specific meaning for it
  519. and depends on that meaning.
  520.  
  521. A primary keyword is equivalent to a verb in the English
  522. language.  It indicates the action taking place.  These keywords
  523. form the basis of the script language. For example, if, goto,
  524. write, etc.
  525.  
  526. A secondary keyword exists only to complement a primary keyword,
  527. and has no meaning by  itself. For example, the if primary
  528. keyword has four secondary keywords associated with itself,
  529. namely: then, elsif, else and endif.
  530.  
  531. For example:
  532.  
  533. if player.name = "Henry" and fighting then
  534.  
  535.   write("Go Away");
  536.  
  537. endif;
  538.  
  539.  
  540.  
  541. In the above line, the if and write keywords are primary,while
  542. then, and endif are secondary because they have a meaning only
  543. in relation to the if keyword. (Note that and is also a
  544. secondary keyword, but has nothing to do with if I didn't
  545. highlight it).
  546.  
  547. A function keyword is used to examine or modify a system value.
  548. This is a value that has a meaning to the game system, but you
  549. can examine and sometimes modify it to change the way the system
  550. behaves.
  551.  
  552. For example, if the keyword fighting in the previous example has
  553. a TRUE value if the game system is currently in combat mode (a
  554. fight is taking place), so the script displays the words 'Go
  555. Away' if the current player's name is Henry and you are fighting.
  556.  
  557. Note that words such as player, npc, object, world,group,  etc.,
  558. are called variables and their qualifiers (like player.name or
  559. world.landscape) are called attributes. These are covered
  560. elsewhere in this manual.
  561.  
  562. The section Writing Scripts in this manual introduces most of
  563. the keywords using simple examples.  A detailed description of
  564. each keyword can be found in the Script Language Reference Guide.
  565.  
  566. List of Primary, Secondary and Function Keywords1
  567.  
  568. Comments
  569.  
  570. A comment is a sequence of characters beginning with the
  571. character '!'.  The exclamation point tells the script language
  572. compiler that the text that follows is a comment and should be
  573. ignored.  Comments are used to document your scripts so they are
  574. easier to understand.
  575.  
  576. For example:
  577.  
  578. ! This is a comment
  579.  
  580.    ! This is also a comment! All of it..
  581.  
  582. !!! This is another comment.
  583.  
  584.  
  585.  
  586. Note that all text following first ! is part of the comment,
  587. including any other ! character.
  588.  
  589. Numbers
  590.  
  591. Numbers are very important in DCGAMES.  
  592.  
  593. They are used extensively to identify the attributes of objects
  594. and characters. As a rule, numbers can be values between
  595. -2147483647 and 2147483647.  While this is true for constants,
  596. when using numbers, you will usually have to restrict them to be
  597. within the range of values allowed for the purpose you are using
  598. the number for.  For example, a ring object has an attribute
  599. called charges which holds the number of times the ring can be
  600. used.  This attribute can have a value between 0 (no charges
  601. left) and 255.  Trying to set the charges attribute to 500 will
  602. result in a warning message, and assign the maximum allowed
  603. value of 255. The range of values that an attribute can take are
  604. documented along with each attribute in the section entitled
  605. STRUCTURES further on in this chapter.
  606.  
  607. Tokens
  608.  
  609. When you write a script, you frequently need to examine and
  610. modify the attributes of objects and characters, or to perform
  611. different actions depending on the values of the same.  While
  612. most of these attributes are numeric, you don't need to remember
  613. what each number means.  Instead, tokens have been defined that
  614. represent the numeric values.  
  615.  
  616. In this document, tokens are shown in UPPER CASE.  Any name
  617. shown in upper case letters can be considered to be a token.
  618.  
  619. For example.  The standard product includes a set of pre-defined
  620. object types such as FOOD, WEAPON, ARMOR, etc.  The game uses a
  621. number to represent the object's type (0, 1, 2, 3, etc), but it
  622. would be difficult to remember that if you want to create a
  623. WEAPON, you need to set the object's type to 1.  Thus, a token
  624. (namely WEAPON) can be used.  A complete list of predefined
  625. tokens, their values and their usage can be found in the
  626. appendix. 
  627.  
  628. If you modify or extend the set of pre-defined element types,
  629. you will also add new tokens to the file DCCTOKEN.DAT, which
  630. associates the token name with the actual value it is going to
  631. represent.  Once the name has been added to the file, you no
  632. longer have to remember what value you were using for your new
  633. 'type' or 'class' or whatever.
  634.  
  635. Variables
  636.  
  637. A variable is a name used to represent a value, just like a
  638. token, but the difference is that the variable holds a value,
  639. and the value can be modified.  For example, an object could
  640. have a weight of 100, but you can change that value any time.
  641.  
  642. Variables are shown in bold letters in this document.  A
  643. variable may have more than one value associated with it (for
  644. example, an object has a name, a value, a weight, etc.).  The
  645. values associated with the variable are called the attributes of
  646. the variable.
  647.  
  648. The following paragraphs hold a complete list of all variables,
  649. their names, attributes, values and a brief description of the
  650. meaning of the associated value.
  651.  
  652. Generic Variables (Local and Global)
  653.  
  654. There are 2048 local variables, named L0 through L2047.  They
  655. can hold values between -32768 and +32767.  They are called
  656. local because they exist only during execution of the script. 
  657. Once the script has been executed, any value you placed in them
  658. is lost.
  659.  
  660. Every time a script starts execution, it's local variables are
  661. initialized to zero.  These variables are used mostly for
  662. control purposes and to hold intermediate values.
  663.  
  664.  
  665.  
  666. There are 2048 global variables, named G0 through G2047.  These
  667. variables can hold values between -32768 and +32767.  They are
  668. called global because they exist for the entire duration of the
  669. game.  If you set one of these variables to a certain value, it
  670. will retain that value until you change it again.  These
  671. variables are used to hold values that are important throughout
  672. the life of the game.  For example, you might use one of these
  673. variables to indicate that a certain action has taken place. 
  674. Other scripts could then check the value of the variable and
  675. take different actions depending on whether the action has taken
  676. place or not.
  677.  
  678.  
  679.  
  680. String Variables
  681.  
  682. There are 17 string variables, named S0 through S16.  They are
  683. different from other variables in that they hold TEXT instead of
  684. numbers.  They are also different in that they are used for some
  685. specific purposes, and so, are not "generic".
  686.  
  687. Variable S0 can contain up to 255 characters. While you can use
  688. it for any purpose, it is also used to store any text that the
  689. player types during conversations, as well as other values.  The
  690. getstr() script function asks the user to type something, and
  691. stores that value in this variable (among other things).
  692.  
  693. Variables S1 through S16 can contain up to 64 characters.  These
  694. variables hold the 16 lines of text associated with the current
  695. object or character.  The loadtext() script function will load a
  696. given text record and place each of the lines in the
  697. corresponding variable.
  698.  
  699. Character Variables and Attributes
  700.  
  701.  
  702.  
  703. A character in the adventure can be a simple 'extra', with no
  704. other function than to  flesh out a story, or it can be an
  705. integral part of it.  Every character is controlled by a script,
  706. and the system includes a large number of predefined scripts to
  707. handle different types of characters.  Amongst the different
  708. types of characters are: Regular, Bartender, Merchant, Civilian,
  709. Quester, Beggar, etc.  Each of these character types has it's
  710. own script,  and when you create a character, you will usually
  711. select one of these scripts to handle it's behavior.  You may
  712. extend the functionality of each character type by modifying the
  713. scripts, or you can create brand new scripts to handle a brand
  714. new type of character.  For those characters that are central to
  715. the story, you may even want to create a special script that
  716. handles their unique behavior.
  717.  
  718.  
  719.  
  720. When referring to characters, you may talk about the player or
  721. the npc. In any interaction, the player is  a member of the 
  722. game player's party.  The npc is the member with which the
  723. player is interacting.
  724.  
  725. Character Attributes     Description 
  726.  
  727. name     Name of the character (15 characters max). 
  728.  
  729. index*     For players, the order in the party. For npcs their
  730. location in the list of npcs. 
  731.  
  732. type     Character Type: (0-255). See tokens in DCCTOKEN.DAT
  733. [Character Types] 
  734.  
  735. class     Character Class (0-255). See tokens in DCCTOKEN.DAT
  736. [Character Class] 
  737.  
  738. block     Tile # from the DCPEOPLE.nnn graphics blocks file used
  739. for this character 
  740.  
  741. block2     Alternate Tile # used in some instances (under script
  742. control only) 
  743.  
  744. picture     Image file (0-999). If given, the file CPICTnnn.PCX
  745. contains the picture. 
  746.  
  747. voice     Voice file (0-999). If given, the file VOICEnnn.RSP
  748. contains the voices. 
  749.  
  750. x     Character's current horizontal location in the current world. 
  751.  
  752. y     Character's current vertical locatioin in the current world. 
  753.  
  754. count     For NPCs only, it's the # of npcs represented by the
  755. individual NPC. 
  756.  
  757. script     Optional SCRIPT for this character. Uses the character
  758. type as default. 
  759.  
  760. text     Optioinal text record (0-n). 
  761.  
  762. load/mload     Current/Maximum load (how much weight can be
  763. carried) 
  764.  
  765. str/mstr     Current/Normal strength  
  766.  
  767. aim/maim     Current/Normal aim 
  768.  
  769. dex/mdex     Current/Normal dexterity 
  770.  
  771. spd/mspd     Current/Normal speed 
  772.  
  773. pwr/mpwr     Current/Normal magical power points 
  774.  
  775. hp/mhp     Current/Normal Hit Points 
  776.  
  777. iq/miq     Current/Normal intelligence 
  778.  
  779. ac/mac     Current/Normal Armor Class 
  780.  
  781. luk/mluk     Current/Normal Luck 
  782.  
  783. chr/mchr     Current/Normal Charisma 
  784.  
  785. exp     Current experience points 
  786.  
  787. level     Current character level 
  788.  
  789. poisoned     Character is poisoned 
  790.  
  791. scared     Character is scared 
  792.  
  793. paralyzed     Character is paralyzed 
  794.  
  795. confused     Character is confused 
  796.  
  797. invisible     Character is invisible 
  798.  
  799. energy     Current energy level (From food.  See group.energy for
  800. energy from sleep). 
  801.  
  802. stats     Character statistics record. 
  803.  
  804. v0 - v7     Extra variables to be used for any purpose you need. 
  805.  
  806. weapon     Currently wielded weapon (if any) 
  807.  
  808. armor     Currently worn armor (if any) 
  809.  
  810. shield     Currently worn shield (if any) 
  811.  
  812. ring     Currently worn ring (if any) 
  813.  
  814. amulet     Currently worn amulet (if any) 
  815.  
  816. staff     Currently wielded staff (if any) 
  817.  
  818. bp     Currently selected backpack object (The backpack can hold
  819. 16) 
  820.  
  821. body     Currently selected body object (if any, one of the
  822. following 6 objects). 
  823.  
  824.  
  825.  
  826. Object Variables and Attributes
  827.  
  828.  
  829.  
  830. An object is an item that can be manipulated in many different
  831. ways during game play.  The object's TYPE and CLASS determine
  832. what can be done with the object.
  833.  
  834. Most of the behavior of objects is controlled from the
  835. predefined script OBJECT.  This script can handle objects of
  836. type food, weapon, ammunition, shield, armor, ring, amulet,
  837. scroll, staff, chest, vehicles, etc.
  838.  
  839. Object Variables     Description 
  840.  
  841. player.weapon     The weapon wielded by the current player (if
  842. any). 
  843.  
  844. player.armor     The armor worn by the current player (if any). 
  845.  
  846. player.shield     The shield being used by the current player (if
  847. any). 
  848.  
  849. player.ring     The ring being worn by the current player (if any). 
  850.  
  851. player.amulet     The amulet being worn by the current player (if
  852. any). 
  853.  
  854. player.staff     The staff being used by the current player (if
  855. any). 
  856.  
  857. player.body     The last selected body item (represents one of
  858. player.weapon, player.armor, player.shield, player.ring,
  859. player.amulet or player.staff. 
  860.  
  861. player.bp     The last selected backpack item for the current
  862. player.  The backpack can hold up to 16 items, but only one of
  863. them is selected at a time. 
  864.  
  865. npc.weapon     The weapon wielded by the current npc (if any). 
  866.  
  867. npc.armor     The armor worn by the current npc (if any). 
  868.  
  869. npc.shield     The shield being used by the current npc (if any). 
  870.  
  871. npc.ring     The ring being worn by the current npc (if any). 
  872.  
  873. npc.amulet     The amulet being worn by the current npc (if any). 
  874.  
  875. npc.staff     The staff being used by the current npc (if any). 
  876.  
  877. npc.body     The last selected body item (represents one of
  878. npc.weapon, npc.armor, npc.shield, npc.ring, npc.amulet or
  879. npc.staff. 
  880.  
  881. npc.bp     The last selected backpack item for the current npc. 
  882. The backpack can hold up to 16 items, but only one of them is
  883. selected at a time. 
  884.  
  885. group.vehicle     The vehicle the group is currently on (if any). 
  886.  
  887. object     The object represented by this variable is not being
  888. carried by anyone. It exists on it's own in the current world. 
  889.  
  890. curritem     The object represented by this variable is being
  891. carried by either the player or the npc character, either in the
  892. backpack or being worn.  It is used when the exact location of
  893. the object is not important.  
  894.  
  895.  
  896.  
  897. Each of the objects listed above has the following attributes
  898. associated with it.  Thus, you can type: npc.weapon.name,
  899. player.bp.count, group.vehicle.type, curritem.class, etc.
  900.  
  901. Object Attributes     Description 
  902.  
  903. name     Name of the object (15 characters max). 
  904.  
  905. index*     Current position of the object in it's place (world,
  906. backpack, etc.) 
  907.  
  908. type     Object Type (0-255). See DCCTOKEN.DAT section [OBJECT
  909. TYPES] 
  910.  
  911. class     Object Class (0-255). See DCCTOKEN.DAT sections [OBJECT
  912. CLASS: x, y] 
  913.  
  914. block     Tile # from file DCOBJECT.mde used to display the object. 
  915.  
  916. picture     Image file # (000-999). If given, file OPICTnnn.PCX
  917. contains the picture. 
  918.  
  919. voice     Vioce file # (000-999). Objects can have a sound file
  920. also VOICEnnn.RSC 
  921.  
  922. weight     Current weight of the object. 
  923.  
  924. value     Current value of the object in Silver Pieces (10sp =
  925. 1gp). 
  926.  
  927. x     Object's horizontal location (when not being carried). 
  928.  
  929. y     Object's vertical location (when not being carried). 
  930.  
  931. count     Number of objects represented by this single instance. 
  932.  
  933. script     Optional script file. Uses OBJECT.SCR and CURRITEM.SCR
  934. by default. 
  935.  
  936. text     Object's text record (if any). 
  937.  
  938. endgame     For compatibility with DCGAMES 1.x/2.x.. 0=No, 1=on
  939. GET, 2=Give. 
  940.  
  941. endtext     Text block # to be displayed when the game ends due to
  942. 'endgame'. 
  943.  
  944. v0 - v7     Extra attributes, use for anything you want. 
  945.  
  946. m0 - m4     Extra attributes, but you can have a token name
  947. associated with one of these. See file DCCTOKEN.DAT for more
  948. info. 
  949.  
  950.  
  951.  
  952. World Variables and Attributes
  953.  
  954.  
  955.  
  956. Each world has a certain number of attributes which you can
  957. examine and in some cases modify.  You can only access the
  958. attributes for the world you are currently in. 
  959.  
  960.  
  961.  
  962. Attribute     Description 
  963.  
  964. name     Name of the current world, text, 15 chars. 
  965.  
  966. index*     Current world number. 
  967.  
  968. type     World's type, 0 - 255. Tokens: OUTDOORS, CITY, TOWN,
  969. DUNGEON, HIDEOUT, HOUSE, CASTLE, ARENA and ENDGAME. 
  970.  
  971. x*     Horizontal size (width) of the current world 
  972.  
  973. y*     Vertical size (height) of the current world 
  974.  
  975. block(x,y)     Landscaping block # displayed at position x,y 
  976.  
  977. density(x,y)     Density of landscaping block at position x,y 
  978.  
  979. level     Minimum player level needed to enter this world. 
  980.  
  981. landscape     Landscaping file being used (0 to 9) 
  982.  
  983. door     the door through which you entered the current world. 
  984.  
  985. doorx(door#)     Horizontal location of the door in the current
  986. world. 
  987.  
  988. doory(door#)     Vertical location of the door in the current
  989. world. 
  990.  
  991. destinationworld(door#)     Destination world # . 
  992.  
  993. destinationdoor(door#)     Destination door in the destination
  994. world. (non-trap doors only) 
  995.  
  996. destinationx(door#)     Horizontal location in the destination
  997. world (trap doors only) 
  998.  
  999. destinationy(door#)     Vertical location in the destination world
  1000. (trap doors only) 
  1001.  
  1002. trapdoorswitch(door#)     Is non-zero if the door is a TRAP
  1003. (destinationx/y instead of destinationdoor). 
  1004.  
  1005.  entrytext(door#)     Text block # displayed when the player enters
  1006. the world through the door. 
  1007.  
  1008. entrytextswitch(door#)     If non-zero, the text is displayed only
  1009. the first time the door is used. 
  1010.  
  1011. exittext(door#)     Text block # displayed when the player exits
  1012. the world through the door 
  1013.  
  1014. exittextswitch(door#)     If non-zero, the text is displayed only
  1015. the first time the door is used. 
  1016.  
  1017. edgedoor     The door through which the player exits the current
  1018. world by walking 'of-the-edge' of the world, or casting the
  1019. standard 'exit' spell. 
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025. Group Variables and Attributes
  1026.  
  1027. Durng game play, your group can contain anywhere from 1 to 6
  1028. characters.
  1029.  
  1030. Group Attributes     Description 
  1031.  
  1032. size*     Current number of characters in the group. 
  1033.  
  1034. current     Currently selected 'spokesbeing' for the group (0-5). 
  1035.  
  1036. gold     Amount of gold being carried (given in silver pieces, 10sp
  1037. = 1gp). 
  1038.  
  1039. food     The total amount of normal (non-magical) food being
  1040. carried by the party. 
  1041.  
  1042. energy     The group's energy, which is replenished with sleep. 
  1043.  
  1044. dead_count     Number of times that everyone in the group has died
  1045. (and thus, how many times they have been resurrected). 
  1046.  
  1047. x     Current horizontal location in the current world. 
  1048.  
  1049. y     Current vertical location in the current world. 
  1050.  
  1051. moves     Total number of moves since the game started. 
  1052.  
  1053. block     Tile # from DCSYSTEM.mde (type 'SYS_PARTY') to represent
  1054. the party during normal game play. 
  1055.  
  1056. vehicle     Current vehicle (if any).  If the group is riding a
  1057. vehicle, the vehicle's graphics block is displayed instead of
  1058. the group's regular block. 
  1059.  
  1060. Types of Scripts
  1061.  
  1062. This section talks about the different TYPES of scripts you may
  1063. want to write, and tries to point out WHY you would want to
  1064. write that kind of script, instead of HOW.  The actual script
  1065. language is presented in the section Script Language Programming
  1066. Guide later in this manual.
  1067.  
  1068. Introduction Script
  1069.  
  1070. The introduction script (INITGAME.SCR) is a script that is
  1071. executed only the first time you start playing. Like most games,
  1072. you must start of by telling the game player what the story is
  1073. about, give some background information, set the mood for the
  1074. game.
  1075.  
  1076. Before this script is invoked, a group with a single player is
  1077. created, taking the attributes from record 0 of the statistics
  1078. file (PLAYERS.DTA) as created using the DCWORLD program.
  1079.  
  1080. The INITGAME script is free to modify the default character, as
  1081. well as add other characters to the group at this time. It can
  1082. also invoke the edit_character function to allow the player to
  1083. select a name, character type, character block and starting
  1084. attributes.
  1085.  
  1086. You can also modify the group's starting position by seting the
  1087. X and Y attributes of the group variable, or by using the
  1088. teleport or enter commands.
  1089.  
  1090. A typical introductory script would look like this:
  1091.  
  1092. !
  1093.  
  1094. ! FILE : initgame.scr
  1095.  
  1096. !
  1097.  
  1098.  
  1099.  
  1100. readtext( "intro.txt" );   ! Read some text
  1101.  
  1102. viewpcx ( "intro2" );      ! Show a nice picture
  1103.  
  1104. music   ( "intro2" );      ! Play background music
  1105.  
  1106. wait    ( 120 );           ! Wait until music ends or <SPACE> is
  1107. pressed
  1108.  
  1109.  
  1110.  
  1111. !
  1112.  
  1113. ! Now, create the player's character by using 'edit_player'
  1114.  
  1115. !
  1116.  
  1117.   edit_player( 1,
  1118.  
  1119.                30, ! points to distribute
  1120.  
  1121.                 9, ! Minimum start attribute value is 9
  1122.  
  1123.                25, ! Maximum start attribute value is 25
  1124.  
  1125.                 1, ! Allow name to be changed
  1126.  
  1127.                 0, ! Don't allow character class to be changed
  1128.  
  1129.                 1  ! Allow character image to be changed
  1130.  
  1131.               );   ! Allow all stats to be changed (strenght,
  1132. dexterity, etc.)
  1133.  
  1134.  
  1135.  
  1136. CONTINUE;          ! Continue with normal character creation
  1137.  
  1138.  
  1139.  
  1140. Note that the READTEXT command has some voice, music and
  1141. graphics capabilities also.  The 'intro.txt' file does not
  1142. necessarily display a single page of text.
  1143.  
  1144. Character Script
  1145.  
  1146. Every character in the game has a script to control it's
  1147. behavior, except for monsters (type HOSTILE), whose behavior
  1148. consists of chasing the player and fighting.
  1149.  
  1150. The world builder assumes that the first 8 characters of the
  1151. character TYPE can be used as the name of the character's
  1152. script.  Thus a BARTENDER's script is BARTENDE.SCR, and a
  1153. BEGGAR's script is BEGGAR.SCR. 
  1154.  
  1155. The system provides 11 predefined character scripts, each of
  1156. which has a unique function.  A full explanation of each
  1157. character 'type' as implemented by the scripts can be found in
  1158. the DCGAMES User's Guide.
  1159.  
  1160. Usually, a character script handles conversation.   When the
  1161. player 'talks' to a character, the character takes control of
  1162. the conversation by means of the script.  A merchant, for
  1163. example, asks if you wish to buy or sell something, while a
  1164. healer asks if you need to be cured, healed, etc.
  1165.  
  1166. Special characters may have their own unique script, as is the
  1167. case of JIMMY in the example adventure.  That script does a bit
  1168. of animation when the character is asked to join the adventurer,
  1169. and handles special needs of that character.
  1170.  
  1171. You should print out the character scripts and compare each of
  1172. them with the description of the character type as given in the
  1173. User's Guide. You will then understand how the given script
  1174. implements the behavior.
  1175.  
  1176. There are three ways of working with character scripts.  You can
  1177. modify the default scripts to alter the behavior of existing
  1178. character types, you can create a brand new character type, with
  1179. it's own script, or you can create a unique script for a unique
  1180. character.
  1181.  
  1182. Object Script
  1183.  
  1184. Unlike characters, objects are not requried to have a script
  1185. associated with them. If they do have one associated, it is
  1186. invoked first to allow it to handle the interaction. If the
  1187. script does not handle the interaction, or it does handle it but
  1188. ends with CONTINUE instead of STOP, or there is no script at
  1189. all, the system invokes one of the default object handling
  1190. scripts: OBJECT.SCR is invoked for objects laying around while
  1191. CURRITEM.SCR is invoked for objects being carried by the player
  1192. or npc.
  1193.  
  1194. Every time you create a new object type or even a new class
  1195. within an object type, you will need to modify the OBJECT and
  1196. CURRITEM scripts to handle the new object.  For example, mirrors
  1197. currently don't do anything.  If you wanted to have a mirror
  1198. that shows you an area around you, you could create mirror
  1199. classes.  Class 0 would be a normal mirror, while class 1 would
  1200. invoke a 'view' spell.  You can then modify the two scripts to
  1201. check the class attribute for mirrors and behave accordingly.
  1202.  
  1203. Note: Since version 4.0 allows one script to call another, this
  1204. description is not entirely correct. The CONTROL script calls
  1205. the OBJECT or CURRITEM scripts as needed, and these scripts may
  1206. call others, like the CASTING script or the DESCOBJ script.
  1207.  
  1208. Now, if you need to have a given object behave differently, you
  1209. need to write a separate script for it.  The script does not
  1210. need to handle all actions on that object, just the ones that
  1211. are different.  For example:  You want to create a magic ring,
  1212. but this ring can cast more than one spell.  You could write a
  1213. special script that has an entry point for the @WEAR action (see
  1214. the programming guide section at the end of this document).  
  1215.  
  1216. When the character wears the ring, your script might display the
  1217. image of a genie, and ask the player what spell is desired.  The
  1218. script would then perform the appropriate spell.
  1219.  
  1220. Remember that if a script does not have an entry point for a
  1221. given action, then a default action is taken.  In this case, the
  1222. default action is to call the CURRITEM script.  Thus, all
  1223. actions would be handled by the CURRITEM script except for WEAR.
  1224.  
  1225. Remember also that if your script ends with CONTINUE instead of
  1226. STOP, the default action is taken anyway, so your script doesn't
  1227. really have to handle the situation.  For example, your 'ring'
  1228. may have a 'random' effect (i.e. you never know what is going to
  1229. happen when you wear it).  To do this, your script would just
  1230. set the ring's class (which determines it's magical effect) and
  1231. terminate with CONTINUE.  The default action would be taken, and
  1232. the CURRITEM script would handle the actual magical effect! World Script
  1233.  
  1234. World scripts are executed whenever you ENTER or EXIT the world.
  1235.  The default world script, WORLDDEF.SCR, is invoked if your
  1236. world does not have it's own script.  The world type and other
  1237. attributes configured using DCWORLD allow the WORLDDEF script to
  1238. handle most normal situations.
  1239.  
  1240. World scripts can be very powerful tools to introduce some
  1241. amount of 'sequencing' into the game.  From within a script you
  1242. can change landscaping, doors, etc.  You can also examine and
  1243. change every single object and character in that world.  You
  1244. could have a character that exists only after you have performed
  1245. a certain action.  The world script could check to see if you
  1246. have performed that action every time you enter the world, and
  1247. create the character only when you have done so.
  1248.  
  1249. You can even re-route the player to a different destination
  1250. within the same world, or in a totally different one.
  1251.  
  1252. See the comments in the WORLDDEF script for a detailed
  1253. discussion of entering and exiting worlds.
  1254.  
  1255. Control Script
  1256.  
  1257. The control script is the most sensitive script of all.  It is
  1258. called under different circumstances and it invokes most of the
  1259. other scripts itself as needed.
  1260.  
  1261. This script is invoked:
  1262.  
  1263. Every 'minute' of game play (as defined in the MovesPerMinute
  1264. control variable) to keep track of time and handle healing,
  1265. getting tired, resting, the appearance of random monsters, etc.
  1266.  
  1267. Every time you press a key or click with the mouse to handle the
  1268. interaction between the player and the game system.
  1269.  
  1270. Once for every player during a fight, to handle a player's TURN.
  1271.  
  1272. Once for every monster during a fight, to handle the monster's
  1273. TURN.
  1274.  
  1275. Note: Version 3.x had entry points in the control script for
  1276. handling a player leaving the party, winning a fight (for
  1277. experience and random treasure), etc. These entrypoints are no
  1278. longer needed because version 4.0 is more fully under script
  1279. control, so these events happen in their appropriate places
  1280. without special "hooks".
  1281.  
  1282. Resurrection Script
  1283.  
  1284. The resurrection script (RESURECT.SCR) is called whenever all
  1285. members of the playing party die.  From this script you have the
  1286. option to give the player a second chance. Once again, you have
  1287. complete control over the situation.  You can terminate the
  1288. game, give the player the option to restart, restore or quit, or
  1289. just restore the player's hit points and continue the game. You
  1290. can also transport the party to another location, and perform
  1291. some cleanup activities.
  1292.  
  1293. Writing Scripts
  1294.  
  1295. Script Files
  1296.  
  1297. A script can be written using any regular text editor or word
  1298. processor.  If you use a word processor, you should save the
  1299. script in ASCII or TEXT format (with no special controls like
  1300. fonts or page formatting).  The script file name should have an
  1301. extension of .SCR, to indicate it contains a script.
  1302.  
  1303. Once the script has been saved, you will use the script compiler
  1304. to translate the script from human readable form (text) into a
  1305. compact code that the game driver understands.  The translated
  1306. code is written into a file with the same name as the original
  1307. file, but with extension of .SCO (for SCript Object).
  1308.  
  1309. For example:
  1310.  
  1311. C:\DCGAME> edit myscript.scr
  1312.  
  1313. ... you create the script using some editor ...
  1314.  
  1315. C:\DCGAME> dir myscript.*
  1316.  
  1317.  
  1318.  
  1319.  Volume in drive C is MYVOLUME
  1320.  
  1321.  Directory of C:\DCGGAME
  1322.  
  1323.  
  1324.  
  1325.  MYSCRIPT SCR      1208 10-29-92   1:25p
  1326.  
  1327.         1 file(s)       1208 bytes
  1328.  
  1329.                      6920192 bytes free
  1330.  
  1331.  
  1332.  
  1333. C:\DCGAME> dcc myscript
  1334.  
  1335. DCGAMES Script Compiler Version 4.0, August 1995
  1336.  
  1337. Copyright (c) 1992 DC Software, 7908 Kettlewood Court, Plano TX
  1338. 75025
  1339.  
  1340. Compiling Script <myscript.SCR>
  1341.  
  1342. Code Size = 179
  1343.  
  1344. Data Size = 367
  1345.  
  1346. Labels    = 25
  1347.  
  1348. Compilation successful
  1349.  
  1350.  
  1351.  
  1352. C:\DCGAME> dir myscript.*
  1353.  
  1354.  
  1355.  
  1356.  Volume in drive C is MYVOLUME
  1357.  
  1358.  Directory of C:\DCGGAME
  1359.  
  1360.  
  1361.  
  1362.  MYSCRIPT SCO       604 10-29-92   1:28p
  1363.  
  1364.  MYSCRIPT SCR      1208 10-29-92   1:25p
  1365.  
  1366.         1 file(s)       1208 bytes
  1367.  
  1368.                      6920192 bytes free
  1369.  
  1370.  
  1371.  
  1372. The script MYSCRIPT is now ready to be used in your adventure. 
  1373. Now, every script must be translated in the above manner
  1374. whenever you modify it, or the changes will not be seen by the
  1375. game driver. The game driver uses the .SCO file only.
  1376.  
  1377. To compile ALL the scripts in your current directory, type:
  1378.  
  1379. C:\DCGAME> for %i in (*.scr) do dcc %i
  1380.  
  1381. If you are familiar with any programming language at all, the
  1382. script language will be quite easy to learn, but even if you
  1383. have never learned any programming language, you should be able
  1384. to learn how to write scripts without to much trouble.
  1385.  
  1386. To assist you, the following section sections try to present the
  1387. script language in easy incremental steps, so you may learn at
  1388. your own pace.
  1389.  
  1390. If you get hopelessly lost, give me a call and I will try to
  1391. assist over the phone, but please give it your best shot and try
  1392. to have specific questions written down when you call.  It will
  1393. help keep the phone call as short as possible.
  1394.  
  1395. I urge you to annotate this document wherever you see think
  1396. something being presented poorly, in the wrong order, or just
  1397. plain wrong. This section is the most important one because it
  1398. is the one that enables YOU to write your games.  Send me a copy
  1399. of the pages on which you have made notes and I will gladly
  1400. correct the problem and send you back a new copy with
  1401. corrections as soon as they are made.
  1402.  
  1403. Expressions and Assignments
  1404.  
  1405. An expression is a list of one or more symbols that represent a
  1406. single value. The symbols may be variables, attributes,
  1407. constants, functions or operands.  We already know what
  1408. variables, attributes and constants are.  An operand is a symbol
  1409. that tells the computer that an operation should take place. 
  1410. For example, in the expression 3 * 5 + 2, the * operand tells
  1411. the computer to multiply the constants 3 and 5, and the symbol +
  1412. tells the computer to add two values together..
  1413.  
  1414. In DCGAMES there are 3 types of expressions, arithmetic,
  1415. relational.
  1416.  
  1417. An arithmetic expression is one which takes numeric values (from
  1418. variables, attributes,  constant or functions) and performs an
  1419. arithmetic operation on them.  The arithmetic operands are: *,
  1420. /, +, - and % (this last representing a modulo operation, or the
  1421. 'remainder' portion of an integer division).
  1422.  
  1423. A relational expression is one which compares two numerical
  1424. expressions and results in a logical value (to be specific, a
  1425. relational expression will always result in either a zero or a
  1426. one).
  1427.  
  1428. A logical value is either zero (meaning FALSE) or non-zero
  1429. meaning true.
  1430.  
  1431. Expressions are used in many places, but the most common use of
  1432. expressions is on the right side of an assignment statement. 
  1433. The second most common use for expressions is as part of a flow
  1434. control statement, such as if or on, which are examined a bit
  1435. later.
  1436.  
  1437. Note that the function keywords listedat the begining of this
  1438. document can be used almost anywhere that you can use an
  1439. expresion. A function has a value which is replaced in the
  1440. position that you use the function itself.  It also may have
  1441. parameters that change the value of the function itself.
  1442.  
  1443. For example, the function abs( - 3 ) has a value of 3, while the
  1444. function max(-5,7,2) has a value of 7.
  1445.  
  1446. This table presents a more detailed description of the
  1447. functions, but a detailed explanation of each of them is found
  1448. in the Script Language Reference Manual.
  1449.  
  1450. Function Table
  1451.  
  1452. Function     Description 
  1453.  
  1454. General     General purpose functions 
  1455.  
  1456. abs(expr)     Returns the value of the expression without a sign
  1457. (removes negative signs) 
  1458.  
  1459. adjustments(expr,...)     Returns the sum of the attribute
  1460. adjustments indicated by the expressions 
  1461.  
  1462. find(where,what,type)     Find an object or character 
  1463.  
  1464. getnum(str,low,high)     Display a message and get a value between
  1465. low and high from the player. 
  1466.  
  1467. getstr(str,...)     Get a string from the player and return the
  1468. index of the matching one. 
  1469.  
  1470. locate(what)     Locate an object or npc character by allowing the
  1471. player to point to it. 
  1472.  
  1473. Time Related     Used to control time during game play 
  1474.  
  1475. MovesPerMinute     Number of moves that can be made in one minute
  1476. of game play. 
  1477.  
  1478. MinutesInAnHour     Number of minutes in one hour of game play. 
  1479.  
  1480. HoursInADay     Number of hours in a day of game play. 
  1481.  
  1482. DaysInAMonth     Number of days in a month of game play. 
  1483.  
  1484. MonthsInAYear     Number of months in a year of game play. 
  1485.  
  1486. Year     The current year. 
  1487.  
  1488. Month     The current month of the current year. 
  1489.  
  1490. Day     The current day of the current month. 
  1491.  
  1492. Hour     The current hour of the current day. 
  1493.  
  1494. Minute     The current minute of the current hour. 
  1495.  
  1496. SunRise     The hour of the day at which the sun rises 
  1497.  
  1498. SunSet     The hour of the day at which the sun sets 
  1499.  
  1500. Monster Related     Used to create random monsters 
  1501.  
  1502. DefStat(0-2)     Backpacks that contain likely treasure (usually
  1503. Potions, Rings and Staffs). 
  1504.  
  1505. DefPack(0-3)     The statistics records for SMALL, MEDIUM, LARGE
  1506. and PIRATE monsters. 
  1507.  
  1508. DefLandBlk(0-4)     Graphics blocks for land based monsters
  1509. (ordered, 0=Easy,4=Very Hard) 
  1510.  
  1511. DefCaveBlk(0-4)     Graphics blocks for cave dwelling monsters
  1512. (ordered) 
  1513.  
  1514. DefWaterBlk(0-4)     Graphics blocks for water dwelling monsters. 
  1515. (ordered, 4=Pirate Ship) 
  1516.  
  1517. DefSpookBlk(0-4)     Graphics blocks of skeletons, ghosts, etc.
  1518. (ordered) 
  1519.  
  1520. expr represents any expression that results in a numeric value     
  1521.  
  1522. ... means that any number of the preceding may be listed,
  1523. separated by commas (up to 255 maximum)     
  1524.  
  1525. The  numeric range (0-N) means that a value in the  given range
  1526. must be provided when referring to this variable     
  1527.  
  1528.  
  1529.  
  1530. Examples:
  1531.  
  1532. ! Increase a player's current level
  1533.  
  1534. player.level = player.level + 1;      
  1535.  
  1536. ! same as "inc(player.level);"
  1537.  
  1538.  
  1539.  
  1540. ! When selling an object, increase the group's gold by half the
  1541. value of the object.
  1542.  
  1543. group.gold = group.gold - player.bp.value / 2; 
  1544.  
  1545. ! same as "dec( group.gold,player.bp.value/2);"
  1546.  
  1547.  
  1548.  
  1549. ! Compute the amount of damage done by a weapon, taking into
  1550. account the wielder's
  1551.  
  1552. ! strength (assumes this is not a missile weapon), where
  1553. strength is not important.
  1554.  
  1555. L25 = npc.weapon.damage + adjustments(npc.str);
  1556.  
  1557.  
  1558.  
  1559. ! NOTE: Since relational expressions return 0 if false and 1 if
  1560. true, the following
  1561.  
  1562. !    expression returns a value between 0 and 7, which is the
  1563. number of attributes
  1564.  
  1565. !    of the current npc that exceed 25 points.
  1566.  
  1567. L7 = npc.str > 25 + npc.aim > 25 + npc.dex > 25 + npc.spd > 25 +
  1568.  
  1569.     npc.pwr > 25 + npc.iq > 25 + npc.chr > 25 + npc.luk > 25;
  1570.  
  1571.  
  1572.  
  1573. ! Change the character's name to "Henry"
  1574.  
  1575. player.name = "Henry";
  1576.  
  1577.  
  1578.  
  1579. Please note that the last assignment statement assigns a string
  1580. value to the name attribute.  The name and script attributes may
  1581. only hold string values.
  1582.  
  1583. Statements
  1584.  
  1585. Just like the English language, the script language uses words
  1586. and symbols to build sentences or statements which tell the game
  1587. driver what to do.  A statement is a complete sequence of words
  1588. and symbols that tell the game driver how to perform a single
  1589. given action.
  1590.  
  1591. A complex statement consists of a one or more statements that
  1592. are grouped together in some fashion to create a more complex
  1593. one. You are already acquainted with the assignment statement,
  1594. now let's look at some other ones, grouped by their nature or
  1595. intended usage.
  1596.  
  1597. Conditional Statements
  1598.  
  1599. In most cases, rather than just assign values to variables, what
  1600. you want to do is take different action depending on certain
  1601. conditions:
  1602.  
  1603. ! Compute the amount of damage done by a weapon, taking into
  1604. account the wielder's
  1605.  
  1606. ! strength IF the weapon is a contact weapon (i.e. not a missile
  1607. weapon).
  1608.  
  1609. if npc.weapon.class = BLUNT or npc.weapon.class = EDGED then
  1610.  
  1611.     L25 = npc.weapon.damage + adjustments(npc.str);
  1612.  
  1613. else
  1614.  
  1615.     L25 = npc.weapon.damage; ! No adjustment for strength
  1616.  
  1617. endif;
  1618.  
  1619.  
  1620.  
  1621. ! The above might also be accomplished as follows
  1622.  
  1623. L25 = npc.weapon.damage;
  1624.  
  1625. if npc.weapon.class = BLUNT or npc.weapon.class = EDGED then
  1626.  
  1627.     L25 = L25 + adjustments(npc.str);
  1628.  
  1629. endif;
  1630.  
  1631.  
  1632.  
  1633. ! Now, the following statement displays the current health
  1634. status of a player
  1635.  
  1636. if player.hp = 0 then
  1637.  
  1638.     writeln( player.name, " is dead!" );
  1639.  
  1640. elsif player.hp = 1 then
  1641.  
  1642.     writeln( player.name, " is unconscious" );
  1643.  
  1644. elsif player.hp < player.mhp
  1645.  
  1646.     writeln( player.name, " is hurt, but still able to function" );
  1647.  
  1648. else
  1649.  
  1650.     writeln( player.name, " is healthy" );
  1651.  
  1652. endif;
  1653.  
  1654.  
  1655.  
  1656. Flow Control Statements
  1657.  
  1658. Sometimes, the if statement can result in long and difficult to
  1659. read statements.  In some cases, it is more appropriate to use
  1660. one of the various forms of the goto or gosub statements to
  1661. accomplish the same goal.
  1662.  
  1663. In order to use these statements, you must first declare one or
  1664. more labels to which the flow of the execution may be
  1665. transferred.  The following examples are equivalent.
  1666.  
  1667. Flow control using if
  1668.  
  1669. :AGAIN
  1670.  
  1671.     L3 = getstr( "Sell", "Buy", "Talk" );
  1672.  
  1673.     if L3 = 0 then
  1674.  
  1675.         ! script for selling goes here
  1676.  
  1677.     elsif L3 = 1 then
  1678.  
  1679.         ! script for buying goes here
  1680.  
  1681.     elsif L3 = 2 then
  1682.  
  1683.         ! script for talking goes here
  1684.  
  1685.     else
  1686.  
  1687.         writeln( "What did you say?" );
  1688.  
  1689.     endif;
  1690.  
  1691.     goto AGAIN;  ! do it again and again, forever.
  1692.  
  1693.  
  1694.  
  1695. Flow control using on-goto
  1696.  
  1697. :AGAIN
  1698.  
  1699.     L3 = getstr( "Sell", "Buy", "Talk" );
  1700.  
  1701.     on L3 goto XSELL, XBUY, XTALK;
  1702.  
  1703.     writeln( "What did you say?" );
  1704.  
  1705.     goto AGAIN;
  1706.  
  1707. :XSELL
  1708.  
  1709.     ! script for selling goes here
  1710.  
  1711.     goto AGAIN;
  1712.  
  1713. :XBUY
  1714.  
  1715.     ! script for buying goes here
  1716.  
  1717.     goto AGAIN;
  1718.  
  1719. :XTALK
  1720.  
  1721.     ! script for talking goes here
  1722.  
  1723.     goto AGAIN;
  1724.  
  1725.  
  1726.  
  1727. When a script is large, a single if statement may be several
  1728. pages long.  It is easy to loose track of what you were trying
  1729. to accomplish.  The on-goto statement has the advantage of
  1730. breaking the logic into separate sections, each self contained
  1731. and self explanatory.   A more complete analysis of the goto,
  1732. gosub, on-goto and on-gosub statements can be found in the
  1733. reference guide.
  1734.  
  1735. Loop Control Statements
  1736.  
  1737. Whenever you need to perform the same operation multiple times,
  1738. a loop statement may come in handy.  The following code shows a
  1739. player giving a copy of everything in his/her backpack to the
  1740. npc character:
  1741.  
  1742. L6 = 0; ! Start with the first backpack object;
  1743.  
  1744. :DOIT
  1745.  
  1746.     setbp(player.bp, L6);        ! Select the Nth backpack object
  1747.  
  1748.     if player.bp.count then        ! If count non-zero, there is an object
  1749.  
  1750.         copy(player.bp,npc);    ! Give a copy of the object
  1751.  
  1752.     endif;
  1753.  
  1754.     inc( L6 );                 ! Same as L6 = L6 + 1;
  1755.  
  1756.     if L6 < 16 goto DOIT;        ! Repeat 16 times
  1757.  
  1758.  
  1759.  
  1760. The above code uses the goto statement to create a loop that
  1761. examines the 16 backpack locations for an object and then copies
  1762. the objects (if they exist) to the npc.
  1763.  
  1764. The while statement
  1765.  
  1766. The while statement simplifies loops by providing an easy way of
  1767. defining a loop without having to declare a label or writing an
  1768. IF statement.  Note that the test for L6 < 16 is made before the
  1769. statements inside the loop are executed.  
  1770.  
  1771. L6 = 0;
  1772.  
  1773. while L6 < 16 do
  1774.  
  1775.     setbp( player.bp, L6 );
  1776.  
  1777.     if player.bp.count then
  1778.  
  1779.         copy( player.bp, npc );
  1780.  
  1781.     endif;
  1782.  
  1783.     inc( L6 );
  1784.  
  1785. endwhile;
  1786.  
  1787.  
  1788.  
  1789. The for statement
  1790.  
  1791. The for statement simplifies the loop even more by allowing you
  1792. to specify both the initial value, the final value and the
  1793. amount by which the control variable (L6) is to be incremented
  1794. (or decremented).  Thus, the loop becomes:
  1795.  
  1796. for L6 = 0 to 15 do
  1797.  
  1798.     setbp( player.bp, L6 );
  1799.  
  1800.     if player.bp.count then
  1801.  
  1802.         copy( player.bp, npc );
  1803.  
  1804.     endif;
  1805.  
  1806. endfor;
  1807.  
  1808.  
  1809.  
  1810. The foreach statement
  1811.  
  1812. To top it of, the foreach statement allows you to select in
  1813. sequence every element of a group.  In this case, the group is
  1814. the set of objects in the backpack.  The foreach loop is
  1815. executed once for each element in the player's backpack.  Empty
  1816. slots are not even selected, so no test is needed.
  1817.  
  1818. Note that if the backpack has NO elements, then the statements
  1819. inside the loop not executed.  This is the best way of examining
  1820. all the elements of a group.
  1821.  
  1822. foreach player.bp do
  1823.  
  1824.     copy( player.bp, npc );
  1825.  
  1826. endfor;
  1827.  
  1828.  
  1829.  
  1830. The foreach statement can select: a) All the characters in the
  1831. player's group, b) All the objects in a character's backpack, c)
  1832. All the objects a character is wearing,  d) All the character's
  1833. in the current world (but not in the player's group) and e) All
  1834. the objects in the current world (but not in anyone's backpack).
  1835.  
  1836. Object Manipulation Statements
  1837.  
  1838. As you saw in the examples above, sometimes you want to move or
  1839. copy objects from one place to another.
  1840.  
  1841. Move and Copy
  1842.  
  1843. When you move an object, it is removed from it's current place
  1844. and inserted in the destination, as long as the destination has
  1845. enough room for it.  If there is not enough room or the
  1846. destination character cannot carry the object, the object is not
  1847. moved. 
  1848.  
  1849. The copy  statement works the same way, but does not delete the
  1850. object from the source, thus making a copy instead of moving the
  1851. object.
  1852.  
  1853. In both cases, you can specify how many objects you want to
  1854. move.  The command will move as many as the destination can
  1855. possibly hold.  If you specify that you want to move or copy
  1856. more objects than are available in the source, additional
  1857. objects are created.
  1858.  
  1859. Drop
  1860.  
  1861. When you drop an object, it is added to the list of objects in
  1862. the world that you are in.  The object will remain where you put
  1863. it.  There are no temporary objects in DCGAMES.
  1864.  
  1865. Output Statements
  1866.  
  1867. Write and Writeln
  1868.  
  1869. When you want to display a value, you have several ways of doing
  1870. it.  The most simple one is the write or writeln statement. 
  1871. With this statement you can display all attributes and variables
  1872. as well as text.
  1873.  
  1874. The following example displays the time of day in the text
  1875. window (assuming that the day has an even number of hours).
  1876.  
  1877. if hour < HoursInADay / 2 + 1 then
  1878.  
  1879.     writeln( "The time is ", Hour, ":", Minute, "am" );
  1880.  
  1881. else
  1882.  
  1883.     L7 = Hour - HoursInADay / 2;
  1884.  
  1885.     writeln( "The time is ", L7, ":", Minute, "pm" );
  1886.  
  1887. endif;
  1888.  
  1889.  
  1890.  
  1891. Display
  1892.  
  1893. The display statement will show a list of items in the menu
  1894. window, with or without numbers or values associated with it. 
  1895. It is useful when you need to show a list of items but are not
  1896. requesting user input.  The many forms of the display statement
  1897. are documented in the reference guide.
  1898.  
  1899. Input Statements
  1900.  
  1901. Frequently, when you display something you are asking the player
  1902. for directions;  During a conversation, you ask the player what
  1903. they want to talk about;  A merchant might display a list of
  1904. items and ask which you want to buy.
  1905.  
  1906. Getstr and Getnum
  1907.  
  1908. The getstr and getnum functions both return a number.  The
  1909. getstr function asks the user to type a string and searches the
  1910. list of strings you provided.  If a match is found, the command
  1911. returns the index of the matching string (i.e. which one
  1912. matched).  If no match is found, the function returns a -1.  In
  1913. any case, the string is stored in the string variable s0.
  1914.  
  1915. The getnum function displays a string and asks the user to enter
  1916. a value in a given range.  Only values in the range are allowed.
  1917.  If the user presses Esc instead of typing a number, the
  1918. function returns -1.
  1919.  
  1920. Select
  1921.  
  1922. The select function displays a menu identical to the one
  1923. displayed by display, but allows the user to select one of the
  1924. entries by using the arrow keys.  This function is used
  1925. extensively, and you should study it with care in the reference
  1926. guide.
  1927.  
  1928. Going Places
  1929.  
  1930. There are several ways in which characters and objects may move
  1931. under script control.
  1932.  
  1933. Animation
  1934.  
  1935. All characters and any object that is not being carried by a
  1936. character has a location within the world reflected by the x and
  1937. y attributes of that character or object.  From a script you may
  1938. modify these attributes and effectively move the characters or
  1939. objects within the limits of the world they are in.  You can
  1940. also change the block attribute to provide some additional
  1941. visual feed back (as long as the character is on screen).
  1942.  
  1943. A small example of animation is presented in the JIMMY.SCR file
  1944. in the example game.  When asked to join the party, Jimmy will
  1945. walk over to his chest and retrieve his weapons, armor and
  1946. money.  He will then walk back towards the player and join the
  1947. party.
  1948.  
  1949. Automatic animation WILL be eventually handled by the system, so
  1950. don't go writing animation routines for every character in your
  1951. game.  This kind of animation should be used in specific
  1952. instances where you want things to happen that the user must not
  1953. be able to prevent or should not have to do him/herself.
  1954.  
  1955. Entering Doors
  1956.  
  1957. The player's party may move from one location to another in
  1958. several ways.  The simplest one is to use the Enter command to
  1959. enter a door.  The party will be transferred to the world and
  1960. destination that the door leads to.
  1961.  
  1962. NOTE: The party will NOT be transferred to the new location
  1963. until the script finishes execution.
  1964.  
  1965. Teleportation
  1966.  
  1967. If you wish to transfer the player to a specific world, you may
  1968. use the Teleport command.  This command allows you to specify a
  1969. destination world (by number) as well as either a door in the
  1970. destination world through which you wish to enter, or the actual
  1971. x and y location at which the party should appear.  Thus, a door
  1972. need not be present in the destination world.
  1973.  
  1974. Advanced Topics
  1975.  
  1976. Entry Points
  1977.  
  1978. Whenever a script is invoked, execution of the script will begin
  1979. at a special label which is called an Entry Point.  The entry
  1980. points are labels of the form :@# where # is a number between 0
  1981. and 20, but, to make life easier, the labels have specific names
  1982. associated with them, which make it easier to remember them. 
  1983. The entry points and the names associated with them are
  1984. different for each type of script, and are shown below:  You
  1985. should use the name form of the entry points unless you have a
  1986. very good reason for using the numbers.
  1987.  
  1988. For Character Scripts
  1989.  
  1990. @TALK        (0)    - Talk to the character
  1991.  
  1992. @DROP        (2)    - Character is being asked to leave the party
  1993.  
  1994. @CAST        (11)    - Character will try to cast a given spell.
  1995.  
  1996. For Object Scripts
  1997.  
  1998. @TALK        (0)    - Talk to an object.
  1999.  
  2000. @GET        (1)    - Move an object into the player's backpack.
  2001.  
  2002. @DROP        (2)    - Drop an object being carried.
  2003.  
  2004. @WEAR        (3)    - Wear an object.
  2005.  
  2006. @REMOVE    (4)    - Remove an object being worn.
  2007.  
  2008. @LOOK        (5)    - Look at an object.
  2009.  
  2010. @EXAMINE    (6)    - Examine an object carefully.
  2011.  
  2012. @INVOKE        (7)    - Invoke the magic in a magical object (ring,
  2013. amulet, etc)
  2014.  
  2015. @USE        (9)     - Use a generic object for whatever purpose it is
  2016. intended.
  2017.  
  2018. @EXIT        (10)    - The player's party wants to get out of a vehicle.
  2019.  
  2020. For World Scripts
  2021.  
  2022. @ENTER        (9)    - The player's party is entering the current world
  2023.  
  2024. @EXIT        (10)    - The player's party is leaving the current world
  2025.  
  2026. For Control Scripts
  2027.  
  2028. n/a            (0)    - Time Control Entry Point.
  2029.  
  2030. n/a            (1)    - Party wants to rest for the night.
  2031.  
  2032. n/a            (2)    - A member of the party wants to leave the group.
  2033.  
  2034. For Magic Spells
  2035.  
  2036. @CAST        (11)    - A magic user has casts a spell.
  2037.  
  2038. For Game Initialization
  2039.  
  2040. n/a            (0)    - Invoked at game initialization
  2041.  
  2042. For Dead and Resurrection
  2043.  
  2044. n/a            (0)    - Invoked when everyone in the party dies.
  2045.  
  2046. Calling A DOS program
  2047.  
  2048. From within a script, you may execute a DOS program by using the
  2049. system command.  This command works exactly like the writeln
  2050. command, except that instead of sending a line of text to the
  2051. text window, the text is formed into an MS-DOS command and
  2052. executed.  When the command ends execution, the MS-DOS error
  2053. level is stored in the failure variable.  A value of 0 usually
  2054. indicates success.
  2055.  
  2056. See the reference guide entry for additional information.
  2057.  
  2058. Creating New Types and Classes
  2059.  
  2060. When the current types and classes of characters, objects or
  2061. worlds is not enough, you may create your own types and classes
  2062. as needed.  The procedure for doing this is highlighted here,
  2063. the assumption is made that you have read the manuals and are
  2064. familiar with the script language before you attempt to add a
  2065. new type or class.
  2066.  
  2067. New Character Types
  2068.  
  2069. To create a new character type, you should edit the file
  2070. DCCTOKEN.DAT, look for the section [CHARACTER TYPES and add an
  2071. entry after the last character type in the file:
  2072.  
  2073.  
  2074.  
  2075. [CHARACTER TYPES]
  2076.  
  2077. REGULAR         0 ! REGULAR.SCR  - Will join the party if asked
  2078. to..
  2079.  
  2080. HOSTILE         1 ! HOSTILE.SCR  - Will attack on sight and
  2081. follow you..
  2082.  
  2083. MERCHANT        2 ! MERCHANT.SCR - Buys and Sells stuff..
  2084.  
  2085. BARTENDER       3 ! BARTENDE.SCR - Sells beer.  Good source of
  2086. information.
  2087.  
  2088. HEALER          4 ! HEALER.SCR   - Cure, Heal, Resurrect, Remove
  2089. Curse,..
  2090.  
  2091. CIVILIAN        5 ! CIVILIAN.SCR - Will talk, but won't join..
  2092.  
  2093. TELLER          6 ! TELLER.SCR   - Fortune Teller or Oracle
  2094. type..
  2095.  
  2096. QUESTER         7 ! QUESTER.SCR  - Asks you to find an object or
  2097. person.
  2098.  
  2099. BEGGAR          8 ! BEGGAR.SCR   - Want's money.  Might give you
  2100. a tip.
  2101.  
  2102. TRAINER         9 ! TRAINER.SCR  - Will train someone
  2103. (STR,DEX,AIM,IQ) 
  2104.  
  2105. GUARD          10 ! GUARD.SCR    - Blocks your way unless given
  2106. the password.
  2107.  
  2108. PRISONER       11 ! PRISONER.SCR - Will join your party
  2109. temporarily (to escape).
  2110.  
  2111. LAWYER         12
  2112.  
  2113. In the above segment, the new character type LAWYER has number
  2114. 12 assigned to it (the next available number).  You may now
  2115. write a script file called LAWYER.SCR to handle the default
  2116. behaviour of lawyers.
  2117.  
  2118. New Character Classes
  2119.  
  2120. Character classes in the current implementation apply only to
  2121. characters that join the party.  The class of the character is
  2122. used to determine what kind of weapons and armor they can use,
  2123. what kind of magic they have, how fast they recover, etc.
  2124.  
  2125. To create a new character class, just edit the DCCTOKEN.DAT file
  2126. and add the new class to the [CHARACTER CLASSES] section:
  2127.  
  2128.  
  2129.  
  2130. [CHARACTER CLASSES]
  2131.  
  2132. HUMAN           0 ! standard stuff, no power 
  2133.  
  2134. ELF             1 ! fast, magical power, not strong 
  2135.  
  2136. DWARF           2 ! slow, STRONG, no magic, no missiles or
  2137. shields 
  2138.  
  2139. WIZARD          3 ! slow, lot's of magic, not strong 
  2140.  
  2141. ARCHER          4 ! fast, no magic, + on missile weapons 
  2142.  
  2143. FIGHTER         5 ! fast, strong, no magic of any kind 
  2144.  
  2145. THIEF           6
  2146.  
  2147.  
  2148.  
  2149. In the above segment, the new character class THIEF has a number
  2150. 6 (next available one).
  2151.  
  2152. The DCBLOCK, DCWORLD, DCPLAY and DCREPORT programs will now
  2153. recognize thieves as a valid character type.
  2154.  
  2155. You may also want to modify the OBJECT and CASTING scripts to
  2156. give a thief certain advantages when dealing with traps, and to
  2157. enable or restrict the kinds of weapons, magic, etc, that the
  2158. character can handle.
  2159.  
  2160. New Object Types
  2161.  
  2162. Creating a new object type is again started by adding the new
  2163. type to the DCCTOKEN.DAT file.  The section [OBJECT TYPES]
  2164. contains the names and numbers for all object types.
  2165.  
  2166. Unlike characters, a single script handles all object types and
  2167. classes.  The OBJECT script should be extended to handle the new
  2168. object type for all it's entry points.
  2169.  
  2170. The object types Food, Weapon, Armor, Shield, Amulet, Ring and
  2171. Staff have special treatment because they can be worn by the
  2172. characters.  The Vehicle  object type also has special handling
  2173. because it can be used for transportation.  Other than these
  2174. special handling, you can modify the OBJECT script file as much
  2175. as you want.
  2176.  
  2177. New Object Classes
  2178.  
  2179. An object class is also represented by a section in the
  2180. DCCTOKEN.DAT file.  It is different from other sections in that
  2181. multiple object types may have the same class (for example:
  2182. rings, amulets, food, potions and gems all have the same class
  2183. set).
  2184.  
  2185. If your new object is going to have the same set of class items
  2186. that already exists for another type, just add the name to the
  2187. list, for example:
  2188.  
  2189. !
  2190.  
  2191. ! Magical Effects, Type 1
  2192.  
  2193. !
  2194.  
  2195. [OBJECT CLASS: FOOD, POTION, RING, AMULET, GEMS, WIDGET]
  2196.  
  2197. NONE            0 ! No magical effect
  2198.  
  2199. CURE            1 ! Remove POISON
  2200.  
  2201. HEAL            2 ! Restore some HP
  2202.  
  2203. POISON          3 ! (Trap) POISON drinker
  2204.  
  2205. RESTORE         4 ! Restore ALL HP
  2206.  
  2207. PLUS_STR        5 ! Increase STRENGTH
  2208.  
  2209. PLUS_DEX        6 ! Increase DEXTERITY
  2210.  
  2211. PLUS_SPD        7 ! Increase SPEED
  2212.  
  2213. PLUS_AIM        8 ! Increase AIM
  2214.  
  2215. PLUS_AC         9 ! Increase AC
  2216.  
  2217. PLUS_HP        10 ! Increase HP
  2218.  
  2219. PLUS_IQ        11 ! Increase IQ
  2220.  
  2221. PLUS_PWR       12 ! Increase POWER
  2222.  
  2223. Here, we have added the new object type WIDGET to the set of
  2224. objects that have personal magic.
  2225.  
  2226. You still have to modify the OBJECT script to handle the
  2227. object's class.  For example, 
  2228.  
  2229.  
  2230.  
  2231.   on object.type goto
  2232.  
  2233.    USE_FOOD,     USE_WEAPON,     USE_AMMO,      USE_ARMOR,     
  2234. USE_SHIELD,
  2235.  
  2236.    USE_AMULET,   USE_RING,       USE_POTION,    USE_SCROLL,    
  2237. USE_STAFF,
  2238.  
  2239.    USE_CHEST,    USE_KEYS,       USE_GEMS,      USE_BOOK,      
  2240. USE_GOLDSACK,
  2241.  
  2242.    USE_TORCH,    USE_LANTERN,    USE_ROPE,      USE_HOOKS,     
  2243. USE_MIRROR,
  2244.  
  2245.    USE_SIGN,     USE_VEHICLE,    USE_WIDGET;
  2246.  
  2247.   .
  2248.  
  2249.   .
  2250.  
  2251.   .
  2252.  
  2253.   :USE_AMULET
  2254.  
  2255.   :USE_RING
  2256.  
  2257.   :USE_ARMOR
  2258.  
  2259.   :USE_WEAPON
  2260.  
  2261.   :USE_SHIELD
  2262.  
  2263.   :USE_STAFF
  2264.  
  2265.      writeln( "You must first 'get' it, then 'wear' or 'wield'
  2266. it.." );
  2267.  
  2268.      STOP;
  2269.  
  2270.   :USE_WIDGET
  2271.  
  2272.      writeln( "If you want to use it, you must first 'get' it.."
  2273. );
  2274.  
  2275.      STOP;
  2276.  
  2277.   .
  2278.  
  2279.   .
  2280.  
  2281. Here, we have decided that a WIDGET must be in the player's
  2282. backpack before it can be used.
  2283.  
  2284. If your new object is different from all other objects, you can
  2285. create a brand new section for it's classes in the DCCTOKEN.DAT
  2286. file:
  2287.  
  2288. !
  2289.  
  2290. ! My WIDGET object classes
  2291.  
  2292. !
  2293.  
  2294. [OBJECT CLASS: widget]
  2295.  
  2296. ROUND        0 ! A round widget
  2297.  
  2298. SQUARE    1 ! A square widget
  2299.  
  2300. OVAL        2 ! An oval widget
  2301.  
  2302. At this point, you may create graphics blocks with type widget
  2303. and class round, square or oval.  You may also write script code
  2304. like this:
  2305.  
  2306. if object.type = widget then
  2307.  
  2308.   on object.class goto XROUND, XSQUARE, XOVAL;
  2309.  
  2310.   writeln( "Unknown widget class.." );
  2311.  
  2312.   stop;
  2313.  
  2314. endif;
  2315.  
  2316. :XROUND  ! Handle a round widget
  2317.  
  2318.  ....
  2319.  
  2320.  STOP;
  2321.  
  2322. :XSQUARE ! Handle a square widget
  2323.  
  2324.  ....
  2325.  
  2326.  STOP;
  2327.  
  2328. :XOVAL   ! Handle an oval widget
  2329.  
  2330.  ....
  2331.  
  2332.  STOP;
  2333.  
  2334. New Object Modifiers
  2335.  
  2336. Each object has 5 attributes that can be used to implement it's
  2337. differences from other objects.  These attributes have names m0
  2338. through m4, but the object modifiers section in the DCCTOKEN.DAT
  2339. file allows you to call them by other names.
  2340.  
  2341. When you create a new object type and/or class, you may want to
  2342. create new names for those fields that you might use to
  2343. differentiate between them  For example:
  2344.  
  2345. [OBJECT MODIFIERS]
  2346.  
  2347.  
  2348.  
  2349. ! Object Type: FOOD
  2350.  
  2351. !          0   Is not used
  2352.  
  2353. UNITS      1 ! If magical, how many units are affected
  2354.  
  2355. PERMANENT  2 ! If magical, how long does effect last? (0=one
  2356. day, 1=permanent)
  2357.  
  2358. !          3   Is not used
  2359.  
  2360. !          4   Is not used
  2361.  
  2362.  
  2363.  
  2364. ! Object Type: WEAPON          
  2365.  
  2366. HANDS      0 ! # of hands needed to use the weapon
  2367.  
  2368. RANGE      1 ! Range of this weapon
  2369.  
  2370. DAMAGE     2 ! Damage done when using this weapon.
  2371.  
  2372. AMMONEEDED 3 ! Type of ammunition needed (See AMMOTYPE below..)
  2373.  
  2374. !          4   Is not used
  2375.  
  2376.  
  2377.  
  2378. ! Object Type: WIDGET
  2379.  
  2380. SIDES      0 ! # of sides that the widget has
  2381.  
  2382. RANGE      1 ! Range of this widget
  2383.  
  2384.  
  2385.  
  2386. Note that if you want to use a token that already has a value
  2387. assigned, like range in the example, which has a value 1
  2388. assigned for weapons, you MUST use the same value for the token.
  2389. Tokens are replaced by their numeric value during compilation,
  2390. so the following two lines are equivalent:
  2391.  
  2392. if object.hands = 7 then ...
  2393.  
  2394. if object.sides = 7 then ...
  2395.  
  2396.  
  2397.  
  2398. Both lines are comparing the m0 modifier of the object with the
  2399. value 7.  The type of the object is not checked to see that the
  2400. token you are using belongs to the object's type.
  2401.  
  2402. New World Types
  2403.  
  2404. Perhaps the easiest to create would be a new world type.  Again,
  2405. just add the entry to the DCCTOKEN.DAT file, section world
  2406. types,  and then edit the WORLDDEF script file to handle the new
  2407. world type.
  2408.  
  2409. Note that many of the currently defined world types have no
  2410. actual differences between them.  For example, Cities, Towns,
  2411. Hideouts, Houses and Castles are all the same..  You can change
  2412. that by modifying the appropriate scripts.
  2413.  
  2414. For example: If you want to make opening a locked chest a crime
  2415. in Castles and Houses, you can add a check in the OBJECT script
  2416. to verify the type of world you are in when the character tries
  2417. to break a lock.
  2418.  
  2419. Shareware Opportunities
  2420.  
  2421. While most users will use the script language to make small
  2422. changes to the game system, with a few customized scripts to
  2423. handle special characters or objects, the true power of scripts
  2424. lies in the ability to completely change the way everything
  2425. works.  Here are a few example of some more complex projects
  2426. that you may want to attempt once you are comfortable writing
  2427. scripts:
  2428.  
  2429. Extending the magic system
  2430.  
  2431.  
  2432.  
  2433. The current magic system allows a character to cast a spell if
  2434. it has the required number of power points.  There is no
  2435. requirement to learn the spells, or to be at a certain level
  2436. before you can cast it.  You can change the OBJECT and CASTING
  2437. scripts to handle a magic book, which can be either a class of
  2438. book (currently, books don't have classes) or a whole new type
  2439. of object (Magic Book).
  2440.  
  2441. You can also change the scripts to handle a lot more spells (up
  2442. to 255 of each type), or add a level requirement for each spell.
  2443.  
  2444. MS-DOS based extensions
  2445.  
  2446. The system command allows you to run DOS programs from within a
  2447. script.  The following DOS programs could be called from a
  2448. script to extend the functionality of the system.  Writing these
  2449. extensions requires knowledge about internal structures of the
  2450. game files, which I will be glad to provide on a case by case
  2451. basis.
  2452.  
  2453. Save/Restore/Restart
  2454.  
  2455. Replace the prompts that perform this function with a window
  2456. that shows saved games along with comments and let's you choose
  2457. which one you want to restore, or lets you specify which slot
  2458. you want to save in, and what comment you want to associate with
  2459. the saved game.
  2460.  
  2461. Character Editor
  2462.  
  2463. Allows you to examine/modify (i.e. cheat) the PARTY file.
  2464.  
  2465. Arcade/Casino extensions
  2466.  
  2467. A completely separate sub-game that is executed when you enter a
  2468. world.  For example, when you enter a casino, you can run a DOS
  2469. game that allows the user to play poker or some other games in
  2470. order to make money.  The program may read the PARTY file to get
  2471. the names of the characters and the amount of gold they have. 
  2472. It would update the gold amount when the characters leave the
  2473. casino.
  2474.  
  2475. Stand Alone Utilities
  2476.  
  2477. A nice utility would be one that can take the game and create
  2478. PCX graphics files for each world, optionally including the
  2479. objects and characters that appear in it.  The PCX file can then
  2480. be scaled and manipulated by other utilities to print maps or
  2481. include the graphics in documentation.
  2482.  
  2483. Writing a whole new system
  2484.  
  2485. It is perfectly feasible to take the rules, character types,
  2486. magic system, etc of game systems such as Dungeons and Dragonstm
  2487. or Man, Myth and Magictm and write them as scripts.  You would
  2488. have to throw away all of the current scripts and write them
  2489. from scratch, but it's perfectly feasible. Of course, these
  2490. systems are copyrighted by their respective publishers, so it
  2491. wouldn't be possible to distribute such a system as shareware (I
  2492. think, but I'm not a copyright expert).
  2493.  
  2494. Primary Keywords
  2495.  
  2496. continue
  2497.  
  2498. copy
  2499.  
  2500. dec
  2501.  
  2502. display
  2503.  
  2504. drop
  2505.  
  2506. endgame
  2507.  
  2508. enter
  2509.  
  2510. fight
  2511.  
  2512. find
  2513.  
  2514. for
  2515.  
  2516. foreach
  2517.  
  2518. frame
  2519.  
  2520. getaction1
  2521.  
  2522. getnum
  2523.  
  2524. getstr
  2525.  
  2526. goto
  2527.  
  2528. gosub
  2529.  
  2530. if
  2531.  
  2532. inc
  2533.  
  2534. join
  2535.  
  2536. leave
  2537.  
  2538. loadhint
  2539.  
  2540. loadtext
  2541.  
  2542. locate
  2543.  
  2544. move
  2545.  
  2546. on
  2547.  
  2548. paint
  2549.  
  2550. pause
  2551.  
  2552. readtext
  2553.  
  2554. restart
  2555.  
  2556. restore
  2557.  
  2558. return
  2559.  
  2560. runscript1
  2561.  
  2562. save
  2563.  
  2564. savepcx1
  2565.  
  2566. select
  2567.  
  2568. setbody
  2569.  
  2570. setbp
  2571.  
  2572. stats
  2573.  
  2574. stop
  2575.  
  2576. teleport
  2577.  
  2578. vanish
  2579.  
  2580. viewfli1
  2581.  
  2582. viewpcx
  2583.  
  2584. voice
  2585.  
  2586. vplay
  2587.  
  2588. wait
  2589.  
  2590. while
  2591.  
  2592. write
  2593.  
  2594. writeln
  2595.  
  2596.  
  2597.  
  2598. Secondary Keywords
  2599.  
  2600. if
  2601.  
  2602. - then, elsif, else, endif
  2603.  
  2604. expression
  2605.  
  2606. - and, or, xor, not
  2607.  
  2608. for
  2609.  
  2610. - to, by, do, endfor
  2611.  
  2612. foreach
  2613.  
  2614. - do, endfor
  2615.  
  2616. while
  2617.  
  2618. - endwhile
  2619.  
  2620. select, display
  2621.  
  2622. - matching
  2623.  
  2624. paint
  2625.  
  2626. - screen, window
  2627.  
  2628.  
  2629.  
  2630. Function Keywords
  2631.  
  2632. abs
  2633.  
  2634. action
  2635.  
  2636. adjustments
  2637.  
  2638. Day
  2639.  
  2640. DaysInAMonth
  2641.  
  2642. DefCaveBlk
  2643.  
  2644. DefLandBlk
  2645.  
  2646. DefPack
  2647.  
  2648. DefSpookBlk
  2649.  
  2650. DefStat
  2651.  
  2652. DefWaterBlk
  2653.  
  2654. fighting
  2655.  
  2656. failure
  2657.  
  2658. Hour
  2659.  
  2660. HoursInADay
  2661.  
  2662. keypress1
  2663.  
  2664. max
  2665.  
  2666. min
  2667.  
  2668. Minute
  2669.  
  2670. MinutesInAnHour
  2671.  
  2672. Month
  2673.  
  2674. MonthsInAYear
  2675.  
  2676. MovesPerMinute
  2677.  
  2678. pointx1
  2679.  
  2680. pointy1
  2681.  
  2682. random
  2683.  
  2684. success
  2685.  
  2686. SunSet
  2687.  
  2688. SunRise
  2689.  
  2690. version
  2691.  
  2692. Year
  2693.  
  2694. 1 Keywords marked with a (1) are new in version 4.0 of DCGAMES!
  2695.  
  2696.